From 071d2a1d69c5bad3d6d4b451a9f7568fbf2507a8 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 27 Nov 2015 18:05:36 +0100 Subject: [PATCH] iconhelper: Move size computation We do a switch on the image type, so compute the size for a certain image type right there. --- gtk/gtkiconhelper.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c index f71c464df5..d4b5aa0b23 100644 --- a/gtk/gtkiconhelper.c +++ b/gtk/gtkiconhelper.c @@ -867,6 +867,14 @@ _gtk_icon_helper_get_size (GtkIconHelper *self, height = (height + scale - 1) / scale; break; + case GTK_IMAGE_ANIMATION: + { + GdkPixbufAnimation *animation = gtk_image_definition_get_animation (self->priv->def); + width = gdk_pixbuf_animation_get_width (animation); + height = gdk_pixbuf_animation_get_height (animation); + break; + } + case GTK_IMAGE_ICON_NAME: case GTK_IMAGE_GICON: if (self->priv->pixel_size != -1 || self->priv->force_scale_pixbuf) @@ -876,7 +884,6 @@ _gtk_icon_helper_get_size (GtkIconHelper *self, case GTK_IMAGE_STOCK: case GTK_IMAGE_ICON_SET: - case GTK_IMAGE_ANIMATION: case GTK_IMAGE_EMPTY: default: break; @@ -893,12 +900,6 @@ _gtk_icon_helper_get_size (GtkIconHelper *self, height = self->priv->rendered_surface_height; cairo_surface_destroy (surface); } - else if (gtk_image_definition_get_storage_type (self->priv->def) == GTK_IMAGE_ANIMATION) - { - GdkPixbufAnimation *animation = gtk_image_definition_get_animation (self->priv->def); - width = gdk_pixbuf_animation_get_width (animation); - height = gdk_pixbuf_animation_get_height (animation); - } else if (self->priv->icon_size != GTK_ICON_SIZE_INVALID) { ensure_icon_size (self, &width, &height); -- 2.30.2